@extends('admin/common')

@section('content')
    <article class="page-container">
        <form action="" method="post" class="form form-horizontal" id="form-member-add">
            <input type="hidden" name="id" value="{{isset($id)?$id:''}}">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
                <div class="formControls col-xs-4 col-sm-4">
                    <input type="text" class="input-text" value="{{ isset($member_info->id)?$member_info->id:'' }}" placeholder="" id="name" name="name">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"> 性别：</label>
                <div class="formControls col-xs-4 col-sm-4">
                    @if(isset($member_info->sex) && $member_info->sex == 2)
                        <div class="radio-box">
                            <input name="sex" type="radio" id="sex-1" value="1"  >
                            <label for="sex-1">男</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="sex-2" name="sex" value="2" checked>
                            <label for="sex-2">女</label>
                        </div>
                    @else
                        <div class="radio-box">
                            <input name="sex" type="radio" id="sex-1" value="1" checked>
                            <label for="sex-1">男</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="sex-2" name="sex" value="2" >
                            <label for="sex-2">女</label>
                        </div>
                    @endif
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">手机：</label>
                <div class="formControls col-xs-4 col-sm-4">
                    <input type="text" class="input-text" value="{{ isset($member_info->mobile)?$member_info->mobile:'' }}" placeholder="" id="mobile" name="mobile">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">openid：</label>
                <div class="formControls col-xs-4 col-sm-4">
                    <input type="text" class="input-text" value="{{ isset($member_info->openid)?$member_info->openid:'' }}" placeholder="" id="openid" name="openid">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"> 状态：</label>
                <div class="formControls col-xs-4 col-sm-4">
                    @if(isset($member_info->status) && $member_info->status ==1)
                        <div class="radio-box">
                            <input name="status" type="radio" id="status-1" value="0" >
                            <label for="sex-1">待审核</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="status-2" name="status" value="1" checked>
                            <label for="sex-2">通过</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="status-3" name="status" value="2">
                            <label for="sex-2">未通过</label>
                        </div>
                    @elseif(isset($member_info->status) && $member_info->status == 0)
                        <div class="radio-box">
                            <input name="status" type="radio" id="status-1" value="0" checked>
                            <label for="sex-1">待审核</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="status-2" name="status" value="1" >
                            <label for="sex-2">通过</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="status-3" name="status" value="2">
                            <label for="sex-2">未通过</label>
                        </div>
                    @else
                        <div class="radio-box">
                            <input name="status" type="radio" id="status-1" value="0" >
                            <label for="sex-1">待审核</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="status-2" name="status" value="1" >
                            <label for="sex-2">通过</label>
                        </div>
                        <div class="radio-box">
                            <input type="radio" id="status-3" name="status" value="2" checked>
                            <label for="sex-2">未通过</label>
                        </div>
                    @endif
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">等级：</label>
                <div class="formControls col-xs-4 col-sm-4">
                    <input type="text" class="input-text" value="{{ isset($member_info->lev_id)?$member_info->lev_id:'' }}" placeholder="" id="lev_id" name="lev_id">
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
    @endsection

@section('script')
    <script type="text/javascript" src="{{asset('admin/lib/jquery.validation/1.14.0/jquery.validate.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/lib/jquery.validation/1.14.0/validate-methods.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/lib/jquery.validation/1.14.0/messages_zh.js')}}"></script>
    <script type="text/javascript">
        $(function(){
            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });

            $("#form-member-add").validate({
                rules:{
                    name:{
                        required:true,
                        minlength:3,
                        maxlength:16
                    },
                    mobile:{
                        required:true,
                        isMobile:true
                    }
                },
                onkeyup:false,
                focusCleanup:true,
                success:"valid",
                submitHandler:function(form){
                    $(form).ajaxSubmit({
                        type : 'post',
                        url : "{{ URL::to('admin/member/addMemberPost') }}" ,
                        success : function(ret){
                            if(ret.code == 1){
                                layer.msg(ret.msg,{icon:1,time:1000},function(){
                                    var index = parent.layer.getFrameIndex(window.name);
                                    //parent.$('.btn-refresh').click();
                                    parent.layer.close(index);
                                });
                            }else{
                                layer.msg(ret.msg,{icon:1,time:1000});
                            }
                        }
                    });
                }
            });
        });
    </script>
@endsection